package com.CGFrame.struts.action.project;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.CGFrame.struts.bean.project.ElementFileBean;
import com.CGFrame.struts.bean.project.ElementFileLogic;

public class InitElementAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		String characters=request.getParameter("chars");
		String props=request.getParameter("props");
		String scenes=request.getParameter("scenes");
		String projectId=request.getParameter("projectId");
		//example: characters="全名1,简称1;全名2,简称2;全名3,简称3;"
		try{
			ElementFileBean eFBean = new ElementFileBean(characters,props,scenes);
			ElementFileLogic.addElements(eFBean, projectId);
		}
		catch(Exception e)
		{
			request.setAttribute("Error","dataformaterror");
			e.printStackTrace();
			return mapping.findForward("failure");
		}
		request.setAttribute("ProjectId", projectId);
		return mapping.findForward("sucess");
	}
	
}
